﻿function OpenFileBrowser(onOk, title) {    
    $('#file-browser-loader').html("loading...");
    $.get('/File/GetManagerView', function (data) {
        $('#file-browser-loader').html(data);
        $("#file-browser-loader").dialog({
            modal: true,
            buttons: {
                Ok: function () {
                    $(this).dialog("close");
                    onOk(selectedFilePath);
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            },
            open: function (event, ui) {

            },
            resizable: false,
            width: 650,
            title: title
        });
    });

}

function browseToFileManagerServer(target, url) {
    var width = 650;
    var height = 320;

    var iLeft = (window.screen.width - width) / 2;
    var iTop = (window.screen.height - height) / 2;

    var sOptions = "toolbar:no;status:no;resizable:yes;dependent:yes;scrollbars:no;center:1";
    sOptions += ";dialogWidth:" + width + 'px';
    sOptions += ";dialogHeight:" + height + 'px';
    sOptions += ";left:" + iLeft + 'px';
    sOptions += ";top:" + iTop + 'px';
    
    var result = window.showModalDialog('/Admin/FileManagerPlugin', "File/Image Management Server", sOptions);
    if (result) {
        target.value = result;
        ImageDialog.showPreviewImage(result);
    }
};